import { createApp } from 'vue'
import { createPinia } from 'pinia'
import 'element-plus/es/components/message/style/index'
import 'element-plus/es/components/message-box/style/index'
import './assets/main.scss'

import App from './App.vue'
import { serverMessage } from './utils/const'

let container: HTMLDivElement | null = null

function mount() {
  if (container) return

  document.body.append((container = document.createElement('div')))
  createApp(App).use(createPinia()).mount(container)
}

if (chrome?.runtime) {
  serverMessage.once('inject', mount)
} else {
  mount()
}
